﻿using System.IO;
using System.Xml.Serialization;

namespace NonLeagueExplorer.Config
{
    public class ConfigFile
    {
        public static void Save(ConfigData p_Config, string p_FileName)
        {
            using (FileStream file = new FileStream(p_FileName, FileMode.Create))
            {
                XmlSerializer serialize = new XmlSerializer(typeof(ConfigData));
                serialize.Serialize(file, p_Config);
            }
        }

        public static ConfigData Load(string p_FileName)
        {
            ConfigData contents = null;

            using (FileStream file = new FileStream(p_FileName, FileMode.OpenOrCreate))
            {
                XmlSerializer serialize = new XmlSerializer(typeof(ConfigData));
                contents = (ConfigData)serialize.Deserialize(file);
            }

            return contents;
        }
    }
}
